feat(garm): add idempotent resource cleanup - #311
Open
yanksyoon wants to merge 2 commits into
Open
Conversation
yanksyoon
requested review from
cbartz,
florentianayuwono,
javierdelapuente,
weiiwang01 and
yhaliaw
as code owners
August 18, 2026 06:11
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an idempotent, retryable cleanup orchestrator for GARM scalesets/runners, intended to safely drain runners (handling asynchronous deletion) and only delete scalesets once they’re observed empty.
Changes:
- Introduces
GarmResourceCleanupto disable scalesets, request eligible runner deletions, poll until empty, then delete scalesets. - Adds unit tests covering the “drain then delete” flow and the “skip already pending deletion” flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
charms/garm/src/resource_cleanup.py |
Adds the cleanup orchestration logic, including deadline/poll loop and per-scaleset draining behavior. |
charms/garm/tests/unit/test_resource_cleanup.py |
Adds unit tests validating the cleanup orchestration ordering and idempotent behavior around pending deletions. |
Suppressed comments (1)
charms/garm/tests/unit/test_resource_cleanup.py:65
- Unit tests in this charm consistently use AAA-style docstrings (arrange/act/assert), e.g.
charms/garm/tests/unit/test_charm_state.py:93-97andcharms/garm/tests/unit/test_scaleset_reconciler.py:174-178. This new test uses a single-line docstring, which diverges from that convention.
"""Already pending runner deletion is observed until the row disappears."""
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
|
|
||
| def test_cleanup_drains_runners_before_deleting_scaleset(): | ||
| """A runner deletion is asynchronous, so scaleset deletion waits for an empty poll.""" |
Comment on lines
+103
to
+107
| if instances: | ||
| errors = self._delete_eligible_instances(instances) | ||
| # Runner deletion is asynchronous; always wait for the next pass | ||
| # before attempting to delete the scaleset. | ||
| return True, errors |
florentianayuwono
approved these changes
Aug 18, 2026
yanksyoon
force-pushed
the
feat/isd-6082-cleanup
branch
from
August 19, 2026 04:28
f851194 to
a91719d
Compare
weiiwang01
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
pytest -q tests/unit/test_resource_cleanup.py tests/unit/test_garm_api.pyStacked on #310 as part of ISD-6082. The charm remove-hook integration follows in the next PR.
Refs: ISD-6082